<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./../css/moneytiao.css">
    <link rel="stylesheet" href="./../css/tongyong.css">
</head>
    <script src="./../js/flexible.js"></script>
    <script src="./../js/aajax.js"></script>
<body>
    <div id="header">
        <a href="./moneyctrl.html">
            <h1> &lt; </h1>
        </a>
        <h1>省钱控&nbsp;-&nbsp;最新优惠</h1>
        <a href="#"><img src="./../assets/images/header_app.png" alt=""></a>
    </div>


    <section id="body">
       <div id="info"></div>
        <!-- <div class="info">
            <h4 class="title"></h4>
            <p class="mall">京东商城|10-22 13:28 chenjin/慢慢买</p>
            <img src="http://img10.360buyimg.com/n7/jfs/t1720/256/513904188/195330/ce31e971/55d2cf3eNc2d117d0.jpg" alt=" ">
        </div>
        <a href="">前往购买</a>
         <img src="./../assets/images/mmbweixin2.png" alt=""> 
    
        

        <!-- <div class="ctrl">
                    <input name="ctl00$ContentBody$Button1" value="" id="ctl00_ContentBody_Button1" class="tjdp" type="submit">
                </div>
            </div>
        </div>
        <div class="tit" id="newcomment"> 提交评论</div>
        <div class="list">
            <ul> </ul>
        </div> -->
    </section>

    <div id="footer">
        <ul>
            <li><a href="">登录</a></li>
            <li><a href="">注册</a></li>
            <li><a href="javascript:void(0)" id="goTop">返回顶部</a></li>
        </ul>
        <div class="footer-bottom">
            <div>
                <a href="">手机APP下载</a>
                <span>慢慢买手机版</span>
                <span>&nbsp;-&nbsp;掌上比价平台</span>
                <p>m.manmanbuy.com</p>
            </div>
        </div>
    </div>
</body>

</html>

<script>
     
    
     function getUrlParams() {
        let url = location.href;
        let regExp = /.*\?([^\?]+)/
        let query = {};//最终处理好的参数
        let search = regExp.exec(url);
        //productid=23&NAME=123"
        // console.log(search);
        search = search[1];
        //有没有多个query参数,有的话肯定以&进行连接
        let searchArr = [];
        if (search.indexOf("&")) {
            searchArr = search.split("&")
        } else {
            search = search.split()
        }

        searchArr.forEach(item => {
            let queryArr = item.split("=");
            query[queryArr[0]] = queryArr[1]
        })

        return query
    }

    let query = getUrlParams();

    console.log(query);


    fetch("http://chst.vip:1234/api/getmoneyctrlproduct?productid=" + query.productid)
        .then(body => body.json())
        .then(res => {
            res = res.result;
            let html = "";
            res.forEach(item => { 
                html+=`
                <div class="info">
                <h4 class="title">${item.productName}</h4>
                <span class="price">${item.productFrom}| ${item.productTime} &nbsp; ${item.productTips}</span>
                <div class="container">
                ${item.productImg2}
                <p class="mall">${item.productInfo},${item.productInfo1}</p>
                </div>
                
                <div class="bigimg">${item.productImg2}</div>
                
                <ul id="disstorck"><li><span>${item.productCity} </span><strong></strong></li></ul>
                </div>
                
                <a href="">前往购买</a>
                <img src="./../assets/images/mmbweixin2.png" alt="">

                
                <div class="ctrl"> ${item.productComment}</div>
               
                
    
                `
            })

            body.innerHTML = html



            let lis = document.querySelectorAll('li');

            [...lis].forEach(li => {
                li.onclick = function () {
                    let productid = this.getAttribute("productid")
                    //点击的时候要跳转到详情页
                    location.href = "moneytiao.html?productid=" + productid
                }
            })
        })

        let goTOP = document.getElementById('goTop');
        goTOP.onclick = function() {
        document.documentElement.scrollTop = 0
        }
        


        
</script>